<%@ taglib prefix="maxlength" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: Easy
  Date: 2017-09-27
  Time: 15:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>

<div class="row">
    <div class="col-md-12">

        <form class="form-horizontal"  id="addAlipayForm">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-6">

                            <div class="form-group">
                                <label class="col-md-3 control-label">支付宝编号</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-eye"></span></span>
                                        <input type="text" class="form-control"  name="appId" placeholder="请输入支付宝编号">
                                    </div>
                                    <span class="help-block">&nbsp;</span>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-md-3 control-label">支付宝公钥</label>
                                <div class="col-md-9 col-xs-12">
                                    <textarea class="form-control" rows="5" id="alipayPublicKey" name="alipayPublicKey"
                                              placeholder="请输入支付宝公钥"></textarea>
                                    <span class="help-block">&nbsp;</span>
                                </div>
                            </div>
                            <%--<div class="form-group">
                                <label class="col-md-3 control-label">停车场</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-eye"></span></span>
                                        <select class="form-control" required id="receiveId" name="receiveId">
                                            <c:forEach items="${parkingList}" var="item">
                                                <option value="${item.id}">${item.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <span class="help-block">请选择所属停车场</span>
                                </div>
                            </div>--%>
                        </div>

                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label">字符集</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-eye"></span></span>
                                        <select name="input-charset" id="input-charset" class="form-control">
                                            <option value="utf-8" selected>utf-8</option>
                                            <option value="gbk">gbk</option>
                                            <option value="gb2312">gb2312</option>
                                        </select>
                                    </div>
                                    <span class="help-block">&nbsp;</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">应用私钥</label>
                                <div class="col-md-9 col-xs-12">
                                    <textarea class="form-control"  rows="5" id="singPrivateKey"  name="signPrivateKey" placeholder="请输入应用私钥"></textarea>
                                    <span class="help-block">&nbsp;</span>
                                </div>
                            </div>

                        </div>

                    </div>
                </div>
                <div class="panel-footer">
                    <input class="btn btn-default" type="button" value="清空" />
                    <input class="btn btn-primary pull-right" type="button" onclick="save();" value="保存" />
                </div>
            </div>
        </form>

    </div>
</div>
<script>


function save() {
    var param = serializeForm("addAlipayForm");
    var signPrivateKey=$("#singPrivateKey").val();
    var alipayPublicKey=$("#alipayPublicKey").val();
    var inputCharset=$("#input-charset").val();
//    if(validform("addAlipayForm").form()){
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: param +"&signPrivateKey=" + signPrivateKey +"&alipayPublicKey=" + alipayPublicKey +"&inputCharset=" + inputCharset,
            async: true,
            url: '/pay/alipay/saveData',
            success: function (data) {
                if (data.success){
                    layer.msg(data.msg,{icon:1,time:1000},function () {
                        layer.close(top.layer_alipayAdd);
                        reloadPage();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }
            },
            error: function () {
                alert("保存未成功")
            }
        })
//    }
}
</script>
